<template>
  <div class="loading" v-if="loading" :class="{ 'fixed': fixed }">
    <img src="@/assets/images/loading.gif" />
    <slot>
      <p>正在加载...</p>
    </slot>

  </div>
</template>

<script setup>
import { reactive, toRefs, ref, onMounted } from 'vue'
const props = defineProps({
  loading: Boolean,
  fixed: Boolean
})

onMounted(() => {
  console.log(props.fixed);
})
</script>
  
<style lang='less' scoped>
.loading {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  width: 100%;
  font-size: 32px;
  text-align: center;

  &.fixed {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  img {
    max-width: 50px;
    margin-right: 20px;
  }
}
</style>